<template>
    <div class="layout-content">
      <div class="content-wrapper">
      <div><Button type="primary" @click="createActivity">创建活动</Button></div> 
      <Search-input></Search-input>
      <Search-radio></Search-radio>
      <Search-list></Search-list>
      <Pager 
      :totalCount="totalCount" 
      :pageSize="pageSize" 
      :pageIndex="pageIndex" 
      @changePage="changePage" 
      @changePageSize="changePageSize"></Pager>
      </div>
    </div>
</template>

<script>
    import SearchInput from './component/SearchInput';
    import SearchRadio from './component/SearchRadio';
    import SearchList from './component/SearchList';
    import Pager from '../../common/pager';
    export default {
        data(){
          return {
             totalCount:100,
             pageSize  :10,
             pageIndex :this.$route.query.pageIndex*1 || 1
          };
        },
        created(){
           //this.$axios.get('http://www.imooc.com/index/getstarlist');
        },
        components:{
          SearchInput,
          SearchRadio,
          SearchList,
          Pager
        },
        methods:{
          createActivity(){
            this.$router.push({path:'/activity/create'});
          },
          changePage(pageIndex){
            this.pageIndex = pageIndex;
            this.$router.push({path:'/activity/search',query: { 'pageIndex': this.pageIndex, 'pageSize' : this.pageSize}});
            this.fetchData();
          },
          changePageSize(pageSize){
            this.pageIndex = 1;
            this.pageSize  = pageSize;
            this.$router.push({path:'/activity/search',query: { 'pageIndex': 1 , 'pageSize' : this.pageSize}}); 
            this.fetchData();
          },
          fetchData(){
            //console.log(this.$route.query.pageIndex);
            //console.log(this.pageIndex);
          }
        }
    }
</script>

<style scoped>
   .content-wrapper{
   	  padding:25px;
   }
   .search-title{
   	  margin-top:20px;
   }
</style>